import CMountMgr from "../SuperMgr/cMountMgr";
import cEnumMds from "../Enum/cEnumMds"
import cModuleMgr from "../SuperMgr/cModuleMgr"
import cMyselfModule from "./cMyselfModule";
import cClubsModule from "./cClubsModule";
import cChatDiresModule from "./cChatDiresModule";
import cChatMsgsModule from "./cChatMsgsModule";
const { ccclass, property } = cc._decorator;
@ccclass
export default class cLobbyMount extends CMountMgr {
    @property(cc.Toggle)
    private toggleChat:cc.Toggle  = null; //聊天
    @property(cc.Toggle) 
    private toggleDire:cc.Toggle  = null; //通讯录
    @property(cc.Toggle) 
    private toggleClue:cc.Toggle  = null; //俱乐部
    @property(cc.Toggle) 
    private toggleSelf:cc.Toggle  = null; //个人中心
    @property(cc.Node) 
    private submoduleN:cc.Node    = null; //子模块
 
    private currentMod:cModuleMgr = null; //当前模块
    //组件脚本启动扩展
    protected extendStart(){
       this.onChangeTheMe()
    }

    //关闭界面
    protected tryStartTheMe(mod:cModuleMgr){
        let later = this.currentMod
        if(later){
            later.changeClose()
        }

        mod.changeStart()
        this.currentMod = mod
    }

    //更新界面
    protected onChangeTheMe(){
        if(this.toggleChat.isChecked){
            //聊天界面
            let mod:cModuleMgr = this.getModule(cEnumMds.mesgsModule)
            if(null == mod){
                mod = new cChatMsgsModule()
                mod.settingscreen(this.submoduleN)
            }
            this.tryStartTheMe(mod)
        }
        else if(this.toggleDire.isChecked){
            //通讯目录
            let mod:cModuleMgr = this.getModule(cEnumMds.diresModule)
            if(null == mod){
                mod = new cChatDiresModule()
                mod.settingscreen(this.submoduleN)
            }
            this.tryStartTheMe(mod)
        }
        else if(this.toggleClue.isChecked){
            //俱乐部
            let mod:cClubsModule = this.getModule(cEnumMds.clubsModule)
            if(null == mod){
                mod = new cClubsModule()
                mod.settingscreen(this.submoduleN)
            }
            this.tryStartTheMe(mod)
        }
        else if(this.toggleSelf.isChecked){
            //个人中心
            let mod:cMyselfModule = this.getModule(cEnumMds.myselModule)
            if(null == mod){
                mod = new cMyselfModule()
                mod.settingscreen(this.submoduleN)
            }
            this.tryStartTheMe(mod)
        }
    }

}
